package com.ayoka.adapter;

import android.widget.ImageView;

import com.ayoka.Constant;
import com.ayoka.R;
import com.ayoka.bean.TrainingBean;
import com.jcp.baselibrary.brvah.BaseSectionQuickAdapter;
import com.jcp.baselibrary.brvah.BaseViewHolder;
import com.jincp.image.load.ImageLoaderOptions;
import com.jincp.image.load.ImageLoaderProxy;
import com.ayoka.mvp.TrainingGroupMVP.TrainingGroupModel.TrainingGroupSectionEntity;

import java.util.List;

/**
 * Created by jinchunping on 2018/4/11.
 */

public class TrainingGroupSectionAdapter extends BaseSectionQuickAdapter<TrainingGroupSectionEntity, BaseViewHolder> {

    private int type;

    public TrainingGroupSectionAdapter(int type) {
        super(R.layout.item_training_group_content, R.layout.item_training_group_header, null);
        this.type = type;
    }

    @Override
    protected void convert(BaseViewHolder holder, TrainingGroupSectionEntity item) {
        TrainingBean trainingBean = item.t;
        ImageLoaderProxy.getInstance().displayImage(trainingBean.ImgUrl, (ImageView) holder.getView(R.id.iv_training_picture), ImageLoaderOptions.getRoundOptions());
        holder.setText(R.id.tv_training_title, trainingBean.Title)
                .setText(R.id.tv_training_description, trainingBean.SubTitle)
                .setText(R.id.tv_training_count, trainingBean.getSoltQuantity());
    }

    @Override
    protected void convertHead(BaseViewHolder holder, TrainingGroupSectionEntity item) {
        if (type == Constant.TrainingType.BASIC) {
            holder.setVisible(R.id.layout_basic_title, true)
                    .setVisible(R.id.layout_advance_title, false)
                    .setText(R.id.tv_basic_title, item.header)
                    .setText(R.id.tv_basic_subtitle, item.subTitle);
        } else if (type == Constant.TrainingType.ADVANCED) {
            holder.setVisible(R.id.layout_basic_title, false)
                    .setVisible(R.id.layout_advance_title, true)
                    .setText(R.id.tv_advance_title, item.header);
        }
    }
}
